﻿@model List<DotNetUniLodz.Models.Article>

@foreach (var item in Model)
{
    <article id="MainArticle">
        <header>
            @Html.ActionLink(item.Article_title, "Details", "Articles", new { id = item.Article_id }, null)
        </header>
        <div>
            <img src="~/@{ 
    if (item.File != null)
    {
               @item.File.File_path
    }
    else
    {
        Write("Images/Uploads/brak.png");
    }}" alt="@item.Article_title" />

            @Html.Partial("_DisplayNewsInfo", item)

            <p>
                @{
    item.Article_text = System.Text.RegularExpressions.Regex.Replace(item.Article_text, "<[^>]*>", string.Empty);
    if (item.Article_text.Length > 200)
    {
        //@Model.Article_text.Substring(0, 200)
                    @Html.Raw(item.Article_text.Substring(0, 200) + "...")
    }
    else
    {
        //@Model.Article_text                    
                    @Html.Raw(item.Article_text)
    }
                }
            </p>
            <footer>
                @Html.ActionLink("Więcej informacji", "Details", "Articles", new { id = item.Article_id }, new { @class = "ArticleMore" })

                @{
    if (item.Event_id != null)
    {                    
@*<a href="@item.Event.Event_link" class="ArticleRegister">@item.Event.Event_name.Substring(0, item.Event.Event_name.Length > 20 ? 17 : item.Event.Event_name.Length) @if (item.Event.Event_name.Length > 20) { Write("..."); }</a>*@
    
        var eventName = item.Event.Event_name.Substring(0, item.Event.Event_name.Length > 20 ? 17 : item.Event.Event_name.Length);
        if (item.Event.Event_name.Length > 20) { eventName += "..."; }
                    @Html.ActionLink(eventName, "Details", "Events", new { id = item.Event.Event_id }, new { @class = "ArticleRegister" })
    }            
                }
            </footer>
        </div>
    </article>
}